<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Operat_Mod extends MY_Model {
	function __construct() {
		parent::__construct ();
		
		parent::newcrud ( 'operat' );
	}
	
	public function create() {
		
		$data = array ('username' => $_POST ["username"], 'password' => $_POST ["userpass"], 

		'operat_type_id' => $_POST ["type_id"], 'create_time' => $_POST ["time"], 'use_it' => $_POST ["use_it"] );
		parent::create ( $data );
	
	}
	
	public function decide_enter() {
		$data = array ('username' => $_POST ["username"], 'password' => $_POST ["password"] );
		$query = $this->db->get_where ( 'operat', $data );
		if ($query->num_rows () > 0) {
			foreach ( $query->result_array () as $row )
				return $row;
		} else {
			return false;
		}
	
	}
	
	public function read_all() {
		return parent::read_all ();
	
	}
	
	public function read_byid($id) {
		return parent::read_byid ( $id );
	}
	
	public function updata_byid($id) {
		
		$data = array ('username' => $_POST ["username"], 'password' => $_POST ["userpass"], 'operat_type_id' => $_POST ["type_id"], 'create_time' => $_POST ["time"], 'use_it' => $_POST ["use_it"] );
		if ($data ['username'] == 'admin') {
			$data ['operat_type_id'] = 1;
		}
		parent::updata_byid ( $id, $data );
	}
	
	public function delete($id) {
		parent::delete ( $id );
	}

}

?>
